package com.ruibang.glass.equipment.controller;

import com.ruibang.glass.common.constants.Constants;
import com.ruibang.glass.equipment.domain.req.device.DeviceCarReq;
import com.ruibang.glass.equipment.entity.device.Crane;
import com.ruibang.glass.equipment.entity.device.DeviceCar;
import com.ruibang.glass.equipment.service.DeviceCarService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * <p>
 *专业车辆服务
 * </p>
 *
 * @author mameng
 * @since 2024-03-20
 */

@RestController
@RequestMapping("/api/equipment/car")
@Api(value = "专业车辆")
public class DeviceCarController {
    @Autowired
    private DeviceCarService deviceCarService;

    @PostMapping("list")
    @ApiOperation(value = "专业车辆列表", response = ResultBody.class)
    public ResultBody getBoilerList(@RequestBody DeviceCarReq craneReq) {
        return ResultBody.success(deviceCarService.queryPage(craneReq));
    }

    @PostMapping("/deleteById")
    @ApiOperation(value = "删除实体", response = ResultBody.class)
    public ResultBody deleteById(@RequestBody DeviceCar crane) {
        deviceCarService.lambdaUpdate().eq(DeviceCar::getId,crane.getId()).set(DeviceCar::getIsDelete, Constants.ONE_STR).update();
        return ResultBody.success();
    }

    @PostMapping("/getPressureVesselById")
    @ApiOperation(value = "获取对象", response = ResultBody.class)
    public ResultBody getBoilerInfoById(@RequestBody DeviceCar crane) {
        DeviceCar byId = deviceCarService.getById(crane.getId());
        return ResultBody.success(byId);
    }

    @PostMapping("/updateBoilerInfo")
    @ApiOperation(value = "更新", response = ResultBody.class)
    public ResultBody updateBoilerInfo(@RequestBody DeviceCar crane) {
        return ResultBody.success(deviceCarService.updateOrAddById(crane));
    }

}
